# Create your views here.
## GData Service
#import activitystream.lib.gdata.youtube
#import activitystream.lib.atom
#import gdata.youtube.service


import urllib, urllib2
import os, stat, time, sha, sys
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from activitystream.lib.xml2dict import fromstring
from conf.SlideShareConf import SlideShareConf
from SlideData import SlideData

def render(template, payload):    
    #payload['userTags'] = getTags()    
    return render_to_response(template, payload)

def index(request):
    conf = SlideShareConf()  
    #tag = 'ayojak'
    sData = SlideData()
    userTags = sData.getTags()
    userSlides = sData.getUserSlides()
    #return HttpResponse('User Name %s '% userTags)
    payload = dict(slidedata = userSlides, slidetag = userTags, owner = conf.getusername())
    return render('slides.html', payload)

def slidesBytag(request,tag_name):
    conf = SlideShareConf()  
    #tag = 'ayojak'
    sData = SlideData()
    userTags = sData.getTags()
    #userSlides = sData.getUserSlides()
    tagSlides = sData.getSlidesByTag(tag_name)
    #return HttpResponse('User Name %s '% userTags)
    payload = dict(slidedata = tagSlides, slidetag = userTags, owner = conf.getusername(),tagName = tag_name)
    return render('slides-tag.html', payload)

def domSlides(request):
    payload = dict(tagName = 'dom')
    return render('slides-dom.html', payload)

def jsonSlides(request):
    payload = dict(tagName = 'json')
    return render('slides-json.html', payload)

def openSlides(request):
    payload = dict(tagName = 'open')
    return render('slides-open.html', payload)

def socialSlides(request):
    payload = dict(tagName = 'social')
    return render('slides-social.html', payload)

def shindigSlides(request):
    payload = dict(tagName = 'shindig')
    return render('slides-shindig.html', payload)

def errorPage(request):
    return render('slideErrorPage.html', payload)